library CombatExperience initializer init requires LegacySystem

	private function FieldExperience takes nothing returns nothing
		local integer i = 1
		local unit u = GetTriggerUnit()
		loop
			exitwhen i>udg_Players
			if IsUnitVisible(u,ConvertedPlayer(udg_Sorted[i])) then
				set udg_Experience[udg_Sorted[i]] = udg_Experience[udg_Sorted[i]] + udg_XPFactor
			endif
			set i=i+1
		endloop
		set u = null
	endfunction

	private function init takes nothing returns nothing	
		local trigger t
		set t = CreateTrigger()
		call TriggerRegisterPlayerUnitEvent(t,Player(13),EVENT_PLAYER_UNIT_DEATH,null)
		call TriggerRegisterPlayerUnitEvent(t,Player(14),EVENT_PLAYER_UNIT_DEATH,null)
		call TriggerAddAction(t,function FieldExperience)
	endfunction



endlibrary